package org.springblade.modules.admin.controller;

import org.springblade.modules.admin.entity.CompanyElevator;
import org.springblade.modules.admin.service.CompanyElevatorService;
import org.springframework.stereotype.Component;
import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.pipeline.Pipeline;

import java.util.List;

/**
 * @author Jackey
 * @date 2023年09月22日 10:07
 */
@Component
public class MyPipeline implements Pipeline {

	private CompanyElevatorService companyElevatorService;

	public MyPipeline(CompanyElevatorService companyElevatorService) {
		this.companyElevatorService = companyElevatorService;
	}

	@Override
	public void process(ResultItems resultItems, Task task) {


		List<CompanyElevator> companyElevatorList = (List<CompanyElevator>) resultItems.get("companyElevator");

		companyElevatorService.saveBatch(companyElevatorList);
//		for (Map.Entry<String, Object> entry : resultItems.getAll().entrySet()) {
//			System.out.println(entry.getKey() + ":\t" + entry.getValue());
//		}

//		Integer count = ReUtil.getFirstNumber(StrUtil.split(resultItems.get("count"), ",").get(0));
//		companyService.update(new LambdaUpdateWrapper<Company>().likeRight(Company::getContent, resultItems.get("USEORGSYSNO")).set(Company::getCount, ObjectUtil.isNull(count) ? 0 : count));

	}
}
